package com.example.redisDemo.test;

public class ThreePointOneLine {

    public boolean isOneLine(double x1, double y1, double x2, double y2, double x3, double y3){
        if (x1 == x2 && x2 == x3 && y1 == y2 && y2 == y3){
            return false;
        }

        if (x1 == x2 && y1 == y2 && x1 != x3 && y1 != y3){
                return false;
        }

        if (x2 == x3 && y2 == y3 && x1 != x3 && y1 != y3){
                return false;
        }
        if (x1 == x2 && x2 == x3) {
            if (y1 != y2 && y2 != y3) {
                return true;
            }
        }

        if (y1 == y2 && y2 == y3) {
            if (x1 != x2 && x2 != x3) {
                return true;
            }
        }

        double slope1 = (y2 - y1) / (x2 - x1);
        double slope2 = (y3 - y2) / (x3 - x2);
        if (slope1 == slope2) {
            return true;
        }
        return false;
    }
}
